/*
********************************************************************************
* Copyright (C) 2021, xiang.D <dx_65535@163.com>.
* All right reserved.
*
* File Name   : main.cc
* Author      :
* Version     : V1.0
* Description :
* Journal     : 2021-1-20 version v1.0
* Brief       : Blog: https://blog.csdn.net/qq_38750572?spm=1001.2014.3001.5343
* Others      :
                Compile command: make
********************************************************************************
*/

#include "control_tower.h"
#include "airplane.h"

#define MAIN_LOGI(fmt, args...) printf(fmt, ##args)
#define MAIN_LOGD(fmt, args...) printf("%d Main D: " fmt, __LINE__, ##args)
#define MAIN_LOGW(fmt, args...) printf("%d Main W: " fmt, __LINE__, ##args)
#define MAIN_LOGE(fmt, args...) printf("%d Main E: " fmt, __LINE__, ##args)
#define MAIN_LOG(fmt, args...)  printf(fmt, ##args)

int main(int argc, char *argv[])
{
    CChengduTowerMediator *theChengduTower = CChengduTowerMediator::GetInstance();
    CAirBusA319 *theAirBus319 = new CAirBusA319();
    theAirBus319->SetMediator(theChengduTower);

    CBoeing737  *theBoeing737 = new CBoeing737();
    theBoeing737->SetMediator(theChengduTower);

    CComacC919  *theCComacC919 = new CComacC919();
    theCComacC919->SetMediator(theChengduTower);

    // 塔台向所有飞机广播，通报姓名
    //MAIN_LOGI("--> Tower Radio: notify name\n");
    theChengduTower->NotifyObserverAll((char *)"Please notify your name");
    MAIN_LOG("\n");

    // AirBus319应答塔台
    theAirBus319->Notify((char *)"This is AirBus319");
    MAIN_LOG("\n");

    // theBoeing737应答塔台
    //MAIN_LOGI("--> Boeing737 Notify\n");
    theBoeing737->Notify((char *)"This is Boeing737");
    MAIN_LOG("\n");

    // CComacC919应答塔台
    //MAIN_LOGI("--> CComacC919 Notify\n");
    theCComacC919->Notify((char *)"This is CComacC919");
    MAIN_LOG("\n");

    delete theAirBus319;
    delete theBoeing737;
    delete theCComacC919;
    return 0;
}